<?php

/**
 * CompraNacional filter form base class.
 *
 * @package    dirsac
 * @subpackage filter
 * @author     Miguel Flores
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseCompraNacionalFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cuenta_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Cuenta'), 'add_empty' => true)),
      'nombre_encargado'  => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'correo_encargado'  => new sfWidgetFormFilterInput(),
      'anexo_encargado'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'proveedor_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ProveedorNacional'), 'add_empty' => true)),
      'tipo'              => new sfWidgetFormFilterInput(),
      'estado'            => new sfWidgetFormFilterInput(),
      'forma_pago'        => new sfWidgetFormChoice(array('choices' => array('' => '', 'Cheque' => 'Cheque', 'Efectivo' => 'Efectivo', 'Tarjeta' => 'Tarjeta'))),
      'plazo_entrega'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'nombre_contacto'   => new sfWidgetFormFilterInput(),
      'correo_contacto'   => new sfWidgetFormFilterInput(),
      'telefono_contacto' => new sfWidgetFormFilterInput(),
      'neto'              => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'iva'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'total'             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'observacion'       => new sfWidgetFormFilterInput(),
      'created_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'cuenta_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Cuenta'), 'column' => 'id')),
      'nombre_encargado'  => new sfValidatorPass(array('required' => false)),
      'correo_encargado'  => new sfValidatorPass(array('required' => false)),
      'anexo_encargado'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'proveedor_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('ProveedorNacional'), 'column' => 'id')),
      'tipo'              => new sfValidatorPass(array('required' => false)),
      'estado'            => new sfValidatorPass(array('required' => false)),
      'forma_pago'        => new sfValidatorChoice(array('required' => false, 'choices' => array('Cheque' => 'Cheque', 'Efectivo' => 'Efectivo', 'Tarjeta' => 'Tarjeta'))),
      'plazo_entrega'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'nombre_contacto'   => new sfValidatorPass(array('required' => false)),
      'correo_contacto'   => new sfValidatorPass(array('required' => false)),
      'telefono_contacto' => new sfValidatorPass(array('required' => false)),
      'neto'              => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'iva'               => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'total'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'observacion'       => new sfValidatorPass(array('required' => false)),
      'created_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('compra_nacional_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'CompraNacional';
  }

  public function getFields()
  {
    return array(
      'id'                => 'Number',
      'cuenta_id'         => 'ForeignKey',
      'nombre_encargado'  => 'Text',
      'correo_encargado'  => 'Text',
      'anexo_encargado'   => 'Number',
      'proveedor_id'      => 'ForeignKey',
      'tipo'              => 'Text',
      'estado'            => 'Text',
      'forma_pago'        => 'Enum',
      'plazo_entrega'     => 'Date',
      'nombre_contacto'   => 'Text',
      'correo_contacto'   => 'Text',
      'telefono_contacto' => 'Text',
      'neto'              => 'Number',
      'iva'               => 'Number',
      'total'             => 'Number',
      'observacion'       => 'Text',
      'created_at'        => 'Date',
      'updated_at'        => 'Date',
    );
  }
}
